﻿using System;
using ApiGateway;
using HttpApiGateway.Model;
using RpcClient;
using RpcHelper.Validate;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Controller
{
    /// <summary>
    /// 接口资源屏蔽
    /// </summary>
    internal class ShieldController : HttpApiGateway.ApiController
    {
        private readonly IResourceShieldService _ShieId;
        public ShieldController(IResourceShieldService shieId)
        {
            this._ShieId = shieId;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public long Add(ShieIdSetParam param)
        {
            return this._ShieId.Add(param);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        public void Delete([NumValidate("rpc.shieId.Id.error", 1)] long id)
        {
            this._ShieId.Delete(id);
        }
        /// <summary>
        /// 获取过期时间
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public DateTime? GetBeOverTime([NumValidate("rpc.shieId.Id.error", 1)] long id)
        {
            return _ShieId.GetBeOverTime(id); 
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public PagingResult<ShieldDatum> Query(PagingParam<ShieIdQueryParam> param)
        {
            ShieldDatum[] list= this._ShieId.Query(param.Param, param.ToBasicPaging(), out long count);
            return new PagingResult<ShieldDatum>(list, count);
        }
        /// <summary>
        /// 设置过期时间
        /// </summary>
        /// <param name="param"></param>
        public void SetBeOverTime(LongNullParam<DateTime?> param)
        {
            this._ShieId.SetBeOverTime(param.Id, param.Param);
        }
    }
}
